<template>
  <view>
    <yy-paging
      v-model="dataList"
      @onRefresh="onRefresh"
      @query="queryList"
      ref="paging"
      :auto="false"
      @scroll="scroll"
      :refresher-enabled="true"
    >
      <template #top>
        <u-navbar
          :is-back="false"
          :background="{ backgroundColor: isScroll ? '#F2F5F7' : 'transparent' }"
          :border-bottom="false"
          :custom-style="{ transition: 'background-color 0.3s ease-in-out' }"
        >
          <view class="grid grid-cols-3 items-center px-3 w-full">
            <view class="flex col-span-1 items-center" @click="vk.navigateBack()">
              <image src="/static/dddr128.png" mode="aspectFill" class="size-6" />
            </view>
            <view class="line-clamp-1 flex col-span-1 justify-center">
              <view class="text-[#000] font-bold text-base"> 已售列表 </view>
            </view>
            <view class="flex col-span-1 justify-end">
              <view class="text-[.875rem] text-[#5C6068]"> </view>
            </view>
          </view>
        </u-navbar>
      </template>
      <template #empty>
        <yy-empty></yy-empty>
      </template>
      <template #loadingMoreNoMore>
        <yy-nomore></yy-nomore>
      </template>
      <view class="flex flex-col gap-6 p-4">
        <view
          v-for="(i, k) in dataList"
          :key="k"
          @click="vk.navigateTo('/pages/my/otherIndex?id=' + i.user.id)"
          class="flex gap-6 justify-between items-center"
        >
          <view class="flex gap-3 items-center">
            <image
              :src="vk.myfn.handleImageUrl(i.user.avatar)"
              class="w-[3rem] h-[3rem] rounded-full flex-none"
              mode="aspectFill"
            />
            <view class="flex flex-col">
              <view class="text-[.9375rem] text-[#161A24] font-medium line-clamp-1">{{ i.user.nickname }}</view>
              <view class="text-[.75rem] text-[#8E9299]">{{ vk.myfn.formatDateTime(i.pay_time) }}</view>
            </view>
          </view>
          <view>{{ i.amount }}钓钻 </view></view
        ></view
      >
    </yy-paging>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        isScroll: false, // 是否滚动
        dataList: [], // 数据列表
        id: '' // 页面传递的id参数
      }
    },
    onLoad(options) {
      this.id = options.id
      setTimeout(() => {
        this.$refs.paging.reload()
      }, 1)
    },
    onShow() {},
    methods: {
      onRefresh() {},
      returnToPage() {
        vk.navigateBack()
      },
      scroll(e) {
        this.isScroll = e.detail.scrollTop > 0
      },
      async queryList(page, limit) {
        let res = await api.soldList({
          id: this.id,
          page,
          limit
        })
        this.$refs.paging.complete(res.data)
      }
    }
  }
</script>

<style lang="scss" scoped></style>
